home *** CD-ROM | disk | FTP | other *** search
- OPT MODULE, PREPROCESS, OSVERSION=37
-
- MODULE 'gadtools', 'libraries/gadtools', 'devices/inputevent',
- 'intuition/gadgetclass', 'intuition/intuition', 'utility/tagitem',
- 'tools/EasyGUI', 'tools/textlen', 'tools/ctype', 'exec/nodes',
- 'exec/lists'
-
- MODULE 'utility'
-
- ->define DCLIST to make EasyGUI's gadget list more readable!
- EXPORT CONST DCLIST=PLUGIN
-
- EXPORT OBJECT dclistview_plugin OF plugin PRIVATE
-
- label
- key
- relx
- rely
- execlist
- current
- top
- disabled
-
- listview:PTR TO gadget
-
- labelhi
-
- dclick
- clicked
-
- maxnode
-
- second1, micros1
- second2, micros2
- vers
-
- ENDOBJECT
-
- -> PROGRAMMER_ID | MODULE_ID
- -> $01 | $FE
-
-
- EXPORT ENUM PLA_DCListView_Label=$810FE001, ->[I..]
- PLA_DCListView_Key, ->[I..]
- PLA_DCListView_RelativeX, ->[I..]
- PLA_DCListView_RelativeY, ->[I..]
- PLA_DCListView_ExecList, ->[ISG]
- PLA_DCListView_Current, ->[ISG]
- PLA_DCListView_Top, ->[.S.]
- PLA_DCListView_DoubleClick, ->[IS.]
- PLA_DCListView_Disabled ->[ISG]
-
-
- PROC dclistview(tags=NIL:PTR TO tagitem) OF dclistview_plugin
-
- DEF key:PTR TO CHAR, relx, rely, current
-
- IF utilitybase
-
- self.label := GetTagData(PLA_DCListView_Label, NIL, tags)
-
- key := GetTagData(PLA_DCListView_Key, NIL, tags)
- self.key := (IF isalpha(tolower(key)) THEN key ELSE NIL)
-
- relx := GetTagData(PLA_DCListView_RelativeX, 5, tags)
- rely := GetTagData(PLA_DCListView_RelativeY, 2, tags)
-
- self.relx := IF relx>=5 THEN relx ELSE 5
- self.rely := IF rely>=2 THEN rely ELSE 2
-
- self.execlist := GetTagData(PLA_DCListView_ExecList, NIL, tags)
- self.maxnode:=max_node(self.execlist)
-
- current := GetTagData(PLA_DCListView_Current, -1, tags)
- self.current:= IF current>=0 THEN current ELSE -1
-
- self.top := -1
-
- self.dclick := GetTagData(PLA_DCListView_DoubleClick, NIL, tags)
-
- self.disabled := GetTagData(PLA_DCListView_Disabled, FALSE, tags)
-
- ELSE
-
- Raise("util")
-
- ENDIF
-
- self.second1:=NIL
- self.second2:=NIL
-
- self.micros1:=NIL
- self.micros2:=NIL
-
- self.vers:=KickVersion(39)
-
- ENDPROC
-
- PROC end() OF dclistview_plugin IS EMPTY
-
- PROC min_size(ta,fh) OF dclistview_plugin
- self.labelhi:=IF self.label THEN fh+5 ELSE 0
- ENDPROC Max(textlen_key(self.label,ta,self.key),self.relx*fh), self.rely*fh+self.labelhi+5
-
- PROC will_resize() OF dclistview_plugin IS (RESIZEX OR RESIZEY)
-
- PROC gtrender(gl,vis,ta,x,y,xs,ys,w) OF dclistview_plugin HANDLE
- self.listview:=CreateGadgetA(LISTVIEW_KIND,gl,
- [x,y+self.labelhi,xs,ys-self.labelhi,self.label,
- ta,0,0,vis,NIL]:newgadget,
- [GTLV_LABELS, self.execlist,
- GA_DISABLED, self.disabled,
- IF self.key THEN GT_UNDERSCORE ELSE TAG_IGNORE, "_",
- GTLV_SELECTED, self.current,
- GTLV_SHOWSELECTED, NIL,
- IF self.vers THEN GTLV_MAKEVISIBLE ELSE GTLV_TOP, (IF self.top>=0 THEN self.top ELSE Max(self.current,0)),
- TAG_DONE])
- IF self.listview=NIL THEN Raise("dclv")
- EXCEPT DO
- ReThrow()
- ENDPROC self.listview
-
- PROC message_test(imsg:PTR TO intuimessage,win:PTR TO window) OF dclistview_plugin
- DEF islist=FALSE
- IF ((imsg.class=IDCMP_VANILLAKEY) AND Not(self.disabled)) THEN RETURN (self.key=tolower(imsg.code))
- IF (imsg.class=IDCMP_GADGETUP)
- IF islist:= (imsg.iaddress=self.listview)
- self.second2:=imsg.seconds
- self.micros2:=imsg.micros
- ENDIF
- ENDIF
- ENDPROC islist
-
- PROC message_action(class,qual,code,win:PTR TO window) OF dclistview_plugin
- DEF newcurrent, func:PTR TO LONG
- SELECT class
- CASE IDCMP_VANILLAKEY
- self.clicked:=FALSE
- IF (qual AND (IEQUALIFIER_LSHIFT OR IEQUALIFIER_RSHIFT))
- newcurrent:=Max(self.current-1, 0)
- ELSE
- newcurrent:=Min(self.current+1, self.maxnode)
- ENDIF
- IF newcurrent=self.current THEN RETURN FALSE ELSE self.current:=newcurrent
- Gt_SetGadgetAttrsA(self.listview,self.gh.wnd,NIL,[GTLV_SELECTED,self.current,
- IF self.vers THEN GTLV_MAKEVISIBLE ELSE GTLV_TOP, self.current,
- TAG_DONE])
- CASE IDCMP_GADGETUP
- IF code=self.current
- self.clicked:=(IF self.clicked THEN FALSE ELSE DoubleClick(self.second1,self.micros1,self.second2,self.micros2))
-
- IF self.clicked AND (self.dclick<>NIL)
-
- func:=self.dclick
-
- func(self, self.current)
-
- RETURN FALSE
-
- ENDIF
-
- ELSE
- self.current:=code
- ENDIF
- ENDSELECT
- self.second1:=self.second2
- self.micros1:=self.micros2
- self.second2:=NIL
- self.micros2:=NIL
- ENDPROC TRUE
-
- ->> dclistview_plugin: set() & get()
-
- PROC set(attr, value) OF dclistview_plugin
-
- SELECT attr
-
- CASE PLA_DCListView_DoubleClick
-
- IF self.dclick<>value THEN self.dclick:=value
-
- CASE PLA_DCListView_ExecList
-
- IF (self.execlist<>value) AND (self.gh.wnd AND self.listview)
-
- self.execlist:=value
- self.maxnode:=max_node(self.execlist)
- self.clicked:=FALSE
-
- Gt_SetGadgetAttrsA(self.listview, self.gh.wnd, NIL, [GTLV_LABELS, self.execlist, TAG_DONE])
-
- ENDIF
-
- CASE PLA_DCListView_Current
-
- IF (self.current<>value) AND (self.gh.wnd AND self.listview)
-
- self.current:= Bounds(value, -1, self.maxnode)
- self.clicked:=FALSE
-
- Gt_SetGadgetAttrsA(self.listview, self.gh.wnd, NIL,
- [GTLV_SELECTED, self.current,
- IF self.vers THEN GTLV_MAKEVISIBLE ELSE GTLV_TOP, Max(self.current, 0),
- TAG_DONE])
-
- ENDIF
-
- CASE PLA_DCListView_Top
-
- IF (self.gh.wnd AND self.listview)
-
- Gt_SetGadgetAttrsA(self.listview, self.gh.wnd, NIL,
- [GTLV_TOP, value,
- TAG_DONE])
-
- ENDIF
-
- CASE PLA_DCListView_Disabled
-
- IF (self.vers AND (self.disabled<>value)) AND (self.gh.wnd AND self.listview)
-
- self.disabled:=value
- self.clicked:=FALSE
-
- Gt_SetGadgetAttrsA(self.listview, self.gh.wnd, NIL,
- [GA_DISABLED, self.disabled,
- TAG_DONE])
-
- ENDIF
-
- ENDSELECT
-
- ENDPROC
-
- PROC get(attr) OF dclistview_plugin
-
- SELECT attr
-
- CASE PLA_DCListView_Current; RETURN self.current, TRUE
- CASE PLA_DCListView_ExecList; RETURN self.execlist, TRUE
- CASE PLA_DCListView_Disabled; RETURN self.disabled, TRUE
-
- ENDSELECT
-
- ENDPROC -1, FALSE
-
- -><
-
- PROC max_node(list:PTR TO lh)
- DEF node:PTR TO ln, i=NIL
- IF list>0
- node:=list.head
- WHILE node.succ
- node:=node.succ
- INC i
- ENDWHILE
- DEC i
- ENDIF
- ENDPROC i
-
-